const app = getApp();
Page({

  data: {
    name:"",
    studentID: "",
    grade: "",
    specialities: "",
    address:"",
    assistant:"",
    phone:""
  },
  onLoad:function(){
    var that=this;
    var student = wx.getStorageSync("student")
    var studentID = student.studentID
    // console.log(studentID)
    wx.cloud.callFunction({
      name: "get_student",
      data: {
        studentID: studentID,
      },
      success(res) {
        console.log("成功", res.result)
        that.setData({
          studentID:res.result[0].studentID,
          name:res.result[0].name,
          grade: res.result[0].grade,
          phone: res.result[0].phone,
          assisant: res.result[0].assisant,
          address: res.result[0].address,
          specialities: res.result[0].specialities,
        })
        }
    })
  },
  onLoad:function(){
    var that=this;
    var student = wx.getStorageSync("student")
    var studentID = student.studentID
    console.log(studentID)
    wx.cloud.callFunction({
      name: "get_student",
      data: {
        studentID: studentID,
      },
      success(res) {
        console.log("成功", res.result)
        that.setData({
          studentID:res.result[0].studentID,
          name:res.result[0].name,
          grade: res.result[0].grade,
          phone: res.result[0].phone,
          assisant: res.result[0].assisant,
          address: res.result[0].address,
          specialities: res.result[0].specialities,
        })
        }
    })
  },

  jump: function (e) {
    //跳转到“个人资料修改页”
    wx.navigateTo({
      url: '/pages/message/student?name=' + encodeURIComponent(this.data.name) + '&studentID=' + encodeURIComponent(this.data.studentID) + '&grade=' + encodeURIComponent(this.data.grade) + '&specialities=' + encodeURIComponent(this.data.specialities),
    })
  },
  change:function(){
    wx.navigateTo({
      url: '/pages/message/student/student?name=' + encodeURIComponent(this.data.name) + '&studentID=' + encodeURIComponent(this.data.studentID) + '&grade=' + encodeURIComponent(this.data.grade) + '&specialities=' + encodeURIComponent(this.data.specialities),
    })
  },
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading()
    this.onShow()
    setTimeout(() => {
      wx.hideNavigationBarLoading()
      wx.stopPullDownRefresh()
    }, 1000);
  }

})